package ch.sv7.tool.dbmanager.util;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.StringTokenizer;

/**
 *
 * @author svt
 *
 */
public class SQLHelper {

	public static int executeSQL(String sql, Connection conn) 
	throws SQLException {
		Statement stmt = null;
		try {
			stmt = conn.createStatement();
			return stmt.executeUpdate(sql);
		} finally {
			stmt.close();
		}
	}
	
	public static void executeMultiSQL(String sql, Connection conn) 
	throws SQLException {
		StringTokenizer tokens = new StringTokenizer(sql, ";");
		while (tokens.hasMoreTokens()){
			String token = tokens.nextToken().trim();
			if (token.length() > 0){
				/*int result = */executeSQL(token, conn);
				//System.out.println(result);
			}
		}
	}
}
